#include"OCQueue.h"
OCQueue * createOCQueue()
{
	OCQueue * queue=(OCQueue*)malloc(sizeof(OCQueue));
	queue->HasElement=0;
	queue->length=0;
	InitializeCriticalSection(&queue->cs);
	return queue;
}
void insert(struct OCQueue *queue,struct OpenClose_CMD *oc_cmd)
{
	EnterCriticalSection(&queue->cs);
	queue->oc_cmd=oc_cmd;
	queue->length=1;
	LeaveCriticalSection(&queue->cs);
}
OpenClose_CMD* pop(OCQueue *queue)
{
	OpenClose_CMD *p_cmd;
	EnterCriticalSection(&queue->cs);
	if(queue->length>0)
		p_cmd=queue->oc_cmd;
	else
		p_cmd=NULL;
	queue->length=0;
	LeaveCriticalSection(&queue->cs);
	return p_cmd;
}
OpenClose_CMD* first(OCQueue *queue)
{
	OpenClose_CMD *p_cmd;
	EnterCriticalSection(&queue->cs);
	p_cmd=queue->oc_cmd;
	LeaveCriticalSection(&queue->cs);
	return p_cmd;
}
int getLength(OCQueue *queue)
{
	return queue->length;
}